package interpreter;

public class InterpreterPattern {

    public static void main(String[] args) {
        Expression freeForAdultsAndHolidays = new AndExpression(
            new TerminalExpression("holidays"), new TerminalExpression("adults"));
        System.out.println(
            freeForAdultsAndHolidays.interpret("Today is holidays, park is free for adults and children."));
        System.out.println(
            freeForAdultsAndHolidays.interpret("Today is working days, park is not free for adults."));

        Expression freeForChildrenOrHolidays = new OrExpression(
            new TerminalExpression("holidays"), new TerminalExpression("children"));
        System.out.println(
            freeForChildrenOrHolidays.interpret("Today is holidays, park is free for adults and children."));
        System.out.println(
            freeForChildrenOrHolidays.interpret("Today is working days, park is free only for children."));
    }
}
